// page/pack-service/pages/government-public/government-public.js
var toolUtils = require("../../../../utils/tool-utils.js")
var httpUtils = require('../../../../utils/https-service-utils.js')
var that
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    getData()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  /**
   * 街道简介
   */
  onStreetDetails:function(){
    toolUtils.pageTo("/page/pack-service/pages/government-public/street-details/street-details?id=" + that.data.group_info.group_id + "&title=" + that.data.group_info.group_name)
  },
  onItemClick:function(e){
    var item = e.currentTarget.dataset.item
    var tag = 0
    if (e.currentTarget.id == "gggs"){
      tag = 1
    } else if (e.currentTarget.id == "hmzc"){
      tag = 2
    }
    toolUtils.pageTo("/page/pack-service/pages/government-public/file-details/file-details?news_id="+item.news_id+"&tag="+tag)
  }
})

function getData(){
  var params = {}
  var StreetInfo = app.getStreetInfo()
  if (StreetInfo && StreetInfo.group_id) {
    params.group_id = StreetInfo.group_id
  }else{
    toolUtils.showFailToast("group_id不能为空")
    return
  }
  httpUtils.getZwgkIndex(params,function(res){
    that.setData({
      group_info: res.group_info,
      gggs_list: res.gggs_list,
      hmzc_list: res.hmzc_list
    })
  },function(e){

  })
}